import {Document, Schema, Model, model} from "mongoose";

interface GamesDocument extends Document, Games {
}

const GamesSchema: Schema = new Schema({
    name: {
        type: String,
        required: true
    },
    appid: {
        type: String,
        required: true,
        unique: true
    },
    secret: {
        type: String,
        required: true
    },
    config: {
        type: Object,
        default: {
            video: 5,
            ip: ['127.0.0.0']
        }
    },
    token: {
        type: Object,
        default: {
            access_token: '',
            expires_at: '',
            expires_in: ''
        }
    }
})

export const GamesModel: Model<GamesDocument> = model<GamesDocument>('Games', GamesSchema)

export interface Games {
    name: string,
    appid: string,
    secret: string,
    config?: Config
}

export interface Config {
    video: number,
    ip: Array<String>
}
